
import time
from datetime import datetime

from selenium.webdriver.common.by import By

from Linkerui.pages.base_page import BasePage


class LoginPage(BasePage):
    USERNAME = (By.XPATH, '//*[@id="pane-first"]/div/form/div[1]/div/div/input')
    PASSWORD = (By.CSS_SELECTOR, '[type="password"]')
    LOGIN_BTN = (By.CSS_SELECTOR,'.login_box_btn')
    SCREEN_DIR = './'

    def login(self, username, password):
        self.send_keys(self.USERNAME, username)
        time.sleep(2)
        now = datetime.now().strftime("%Y%m%d_%H%M%S")
        file_name = f"{now}.png"
        file_path = self.SCREEN_DIR + file_name

        self.driver.save_screenshot(str(file_path))

        self.send_keys(self.PASSWORD, password)
        time.sleep(2)
        self.click(self.LOGIN_BTN)
        print(self.click(self.LOGIN_BTN))
        time.sleep(9)
        print('wancheng')



